﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace TOOL_S01_EP02
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void OpenFiles_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog _dlg = new Microsoft.Win32.OpenFileDialog
            {
                Multiselect = true
            };
            Nullable<bool> result = _dlg.ShowDialog();
            if (result == true)
            {
                LogDataSummary _logDataSummary = new LogDataSummary(_dlg.FileNames);
                string _strStartTime = _logDataSummary.CmdSendedList[0].Substring(17, 19);
                string _strEndTime = _logDataSummary.CmdSendedList.Last().Substring(17, 19);

                KafakSendCount.Text = "Kafka Sended : " + _logDataSummary.KfkSendedList.Count;
                CommandSendCount.Text = "Command Sended : " + _logDataSummary.CmdSendedList.Count;
                BusCount.Text = "Bus Count : " + _logDataSummary.BuscodeTerminalKey.Count;
                TimeDuration.Text = "Time From " + _strStartTime + " To " + _strEndTime;
                try
                {
                    SnapCatchRatio.Text = "Snap Caught Ratio : " + 100*_logDataSummary.KfkSendedList.Count / _logDataSummary.CmdSendedList.Count + '%';
                }
                catch (Exception ex){ }

            }

           
        }
    }
}
